home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / cgraphix / kinit.c < prev   
C/C++ Source or Header  |  1986-05-08  |  3KB  |  136 lines

  1. /* «RM120»«PL99999»«TS4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76» */
  2. #include    <stdio.h>
  3. #define    EXTERN    extern
  4. #include    <typedef.h>
  5.  
  6.  
  7. void InitGraphic()
  8. {
  9.     extern char    *malloc();
  10.     extern char    *fgets();
  11.  
  12.     FILE        *fd;
  13.     char        *inbuff[85];
  14.     int            fil, i;
  15.  
  16.     GotoXY(1,1);
  17.     if (!HardwarePresent()) {
  18.         ClearScreen();
  19.         GotoXY(1,2);
  20.         fprintf(stderr,
  21.         "Fatal error: graphics hardware not found or not properly activated.\n");
  22.         exit(1);
  23.     }
  24.     MessageGlb = TRUE;
  25.     BrkGlb = FALSE;
  26.     GrafModeGlb = FALSE;
  27.  
  28.     ErrorProc[0] = "InitGraphic";
  29.     ErrorCode[0] = "ERROR.MSG missing";
  30.  
  31.     if (NULL == (fd = fopen("error.msg", "r"))) {
  32.         ErrorProc[1] = "** UNKNOWN **";
  33.         for (i = 2; i <= MaxProcsGlb; i++)
  34.             ErrorProc[i] = ErrorProc[1];
  35.         for (i = 1; i <= MaxErrsGlb; i++)
  36.             ErrorCode[i] = ErrorProc[1];
  37.         error(0,0);
  38.     }
  39.     else {
  40.         for (i = 0; i < MaxProcsGlb; i++) {
  41.             if (NULL == (fgets(inbuff, 80, fd))) {
  42.                 fprintf(stderr,
  43.                     "Premature EOF while reading procs from Error.msg\n");
  44.                 fclose(fd);
  45.                 exit(1);
  46.             }
  47.             else {
  48.                 if (NULL == (ErrorProc[i] = malloc(1 + strlen(inbuff)))) {
  49.                     fprintf(stderr,
  50.                         "Out of memory loading error.msg (proc)\n");
  51.                     fclose(fd);
  52.                     exit(1);
  53.                 }
  54.                 strcpy(ErrorProc[i], inbuff);
  55.             }
  56.         }
  57.         for (i = 0; i < MaxErrsGlb; i++) {
  58.             if (NULL == (fgets(inbuff, 80, fd))) {
  59.                 fprintf(stderr,
  60.                     "Premature EOF while reading errs from Error.msg\n");
  61.                 fclose(fd);
  62.                 exit(1);
  63.             }
  64.             else {
  65.                 if (NULL == (ErrorCode[i] = malloc(1 + strlen(inbuff)))) {
  66.                     fprintf(stderr,
  67.                         "Out of memory loading error.msg (errs)\n");
  68.                     fclose(fd);
  69.                     exit(1);
  70.                 }
  71.                 strcpy(ErrorCode[i], inbuff);
  72.             }
  73.         }
  74.         fgets(inbuff, 80, fd);
  75.         strcpy(PcGlb, inbuff);
  76.         fclose(fd);
  77.     }
  78.  
  79.     for (i = 1; i <= MaxWorldsGlb; i++)
  80.         DefineWorld(i, (double)0, (double)0, (double)XScreenMaxGlb,
  81.             (double)YMaxGlb);
  82.     MaxWorldGlb = 1;
  83.  
  84.     for (i = 1; i <= MaxWindowsGlb; i++) {
  85.         DefineWindow(i,0,0,XMaxGlb,YMaxGlb);
  86.         Stack[i].W.size = 0;
  87.         Stack[i].Contents = NULL;
  88.         RemoveHeader(i);
  89.     }
  90.     MaxWindowGlb = 1;
  91.  
  92.     if (strlen(CharFile) > 0) {
  93.         if (0 > (fil = open(CharFile, BREAD)))
  94.             error(0, 1);
  95.         else
  96.             read(fil, CharSet, 285);
  97.         close(fil);
  98.     }
  99.     BrkGlb = TRUE;
  100.  
  101.     if (RamScreenGlb) {
  102.         if (AllocateRAMScreen()) {
  103.             fprintf(stderr, "RAM Screen cannot be allocated.\n");
  104.             RamScreenGlb = FALSE;        /* RAM Screen not allocated            */
  105.         }
  106.         else {
  107.             SelectScreen(2);
  108.             ClearScreen();
  109.         }
  110.     }
  111.  
  112.     SelectScreen(1);
  113.     WindowNdxGlb = 1;
  114.     SelectWorld(1);
  115.     SelectWindow(1);
  116.     SetColorWhite();
  117.     SetClippingOn();
  118.     SetAspect((double)AspectFactor);
  119.     DirectModeGlb = FALSE;
  120.     PieGlb = FALSE;
  121.     SetMessageOn();
  122.     SetHeaderOff();
  123.     SetHeaderToTop();
  124.     ErrCodeGlb = 0;
  125.     SetLineStyle(0);
  126.     VStepGlb = IVStepGlb;
  127.     EnterGraphic();
  128.     X1Glb = 0;
  129.     X2Glb = 0;
  130.     Y1Glb = 0;
  131.     Y2Glb = 0;
  132.     AxisGlb = FALSE;
  133.     HatchGlb = FALSE;
  134. }
  135.  
  136.